cd ""

import delimited "Dating Survey 4_April 22, 2019_16.00.csv", encoding(ISO-8859-1) clear

gen treatment=0 if fl_33_do_control==1 | fl_34_do_control==1 | fl_35_do_control==1 // control: saw no partisan information (female first, male second)
replace treatment=1 if fl_33_do_republican==1 | fl_34_do_republican==1 | fl_35_do_republican==1 // republican (female first, male second)
replace treatment=2 if fl_33_do_democrat==1 | fl_34_do_democrat==1 | fl_35_do_democrat==1 // democrat (female first, male second)

gen attractiveness_score=q40_1
replace attractiveness_score=q28 if attractiveness_score==.
egen attractiveness_score_std=std(attractiveness_score), mean(0) std(1)

gen message=q42
replace message=q30 if message==.
recode message (1=6) (2=5) (3=4) (4=3) (5=2) (6=1), gen(message_recode)
egen message_recode_std=std(message_recode), mean(0) std(1)
       
gen go_on_a_date=q32
replace go_on_a_date=q44 if go_on_a_date==.
recode go_on_a_date (1=6) (2=5) (3=4) (4=3) (5=2) (6=1), gen(go_on_a_date_recode)
egen go_on_a_date_recode_std=std(go_on_a_date_recode), mean(0) std(1)

gen relationship=q34
replace relationship=q46 if relationship==.
recode relationship (1=6) (2=5) (3=4) (4=3) (5=2) (6=1), gen(relationship_recode)
egen relationship_recode_std=std(relationship_recode), mean(0) std(1)

gen setup=q36
replace setup=q48 if setup==.
recode setup (1=6) (2=5) (3=4) (4=3) (5=2) (6=1), gen(setup_recode)
egen setup_recode_std=std(setup_recode), mean(0) std(1)




gen same_party = .
replace same_party = 0 if q13 == 1 & treatment == 2
replace same_party = 0 if q13 == 2 & treatment == 1
replace same_party = 1 if q13 == 1 & treatment == 1
replace same_party = 1 if q13 == 2 & treatment == 2
	   
	   
regress attractiveness_score i.treatment


regress attractiveness_score i.treatment if q13==1
regress attractiveness_score i.treatment if q13==2
regress attractiveness_score same_party

regress attractiveness_score_std same_party // for the meta-analysis of attractiveness
regress message_recode_std same_party
regress go_on_a_date_recode_std same_party
regress relationship_recode_std same_party
regress setup_recode_std same_party

gen age=q1+15

regress attractiveness_score_std same_party if age<=35


******************************************************************************** Factor Weighted Scale


*No set up so we can be consistent about what is going into the scale (CCES doesn't have setup)
factor attractiveness_score message_recode go_on_a_date_recode relationship_recode
predict interact_scale

egen interact_scale_std=std(interact_scale), mean(0) std(1)

regress interact_scale_std same_party	
	
	
	

***********************************************************
*************************Balance Tests ********************
***********************************************************

*age (already coded)

*gender
gen male = .
replace male = 1 if q3 == 1
replace male = 0 if q3 == 2

*education
gen educ = q4

*race
gen white = 1 if q14_1==1
replace white = 0 if q14_1==.

*marriage status
gen married=1 if q5==1
replace married=0 if q5~=1 & q5~=.

*sexuality
gen straight = .
replace straight = 1 if q7 == 1
replace straight = 0 if q7 != 1 & q7 !=.

*transgender
gen trans = .
replace trans = 1 if q8 == 3
replace trans = 0 if q8 == 1 | q8 == 2

*religiosity
gen religiosity = .
replace religiosity = 1 if q16 == 5
replace religiosity = 2 if q16 == 4
replace religiosity = 3 if q16 == 3
replace religiosity = 4 if q16 == 2
replace religiosity = 5 if q16 == 1

*ideology
gen ideo5 = .
replace ideo5 = 1 if q12 == 5
replace ideo5 = 2 if q12 == 4
replace ideo5 = 3 if q12 == 3
replace ideo5 = 4 if q12 == 2
replace ideo5 = 5 if q12 == 1

*partyid
gen democrat_respondent=1 if q13==2
replace democrat_respondent=0 if q13==1 |  q13==3

*political interest
gen poli_interest = .
replace poli_interest = 1 if q9 ==4
replace poli_interest = 2 if q9 == 2
replace poli_interest = 3 if q9 == 3
replace poli_interest = 4 if q9 == 1

*employment
gen employed=1 if q10==1
replace employed=0 if q10~=1 & q10~=.

*income
gen income = .
replace income = 1 if q11 == 1
replace income = 2 if q11 == 2
replace income = 3 if q11 == 3
replace income = 4 if q11 == 4
replace income = 5 if q11 == 5
replace income = 6 if q11 == 6
replace income = 7 if q11 == 7
replace income = 8 if q11 == 8
replace income = 9 if q11 == 9
replace income = 10 if q11 == 10
replace income = 11 if q11 == 11
replace income = 12 if q11 == 12
replace income = 13 if q11 == 13
replace income = 14 if q11 == 14
replace income = 15 if q11 == 15
replace income = 16 if q11 == 16
replace income = 17 if q11 == 17

***********************************************************
*************************Balance Tests ********************
***********************************************************

sum age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income


egen age_std=std(age), mean(0) std(1)

regress age_std same_party
regsave same_party using "balance_experiment_4.dta", detail(all) addlabel(outcome, age, experiment, 4) replace 





foreach var in  male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
egen `var'_std=std(`var'), mean(0) std(1)
regress `var'_std same_party
regsave same_party using "balance_experiment_4.dta", detail(all) addlabel(outcome, `var', experiment, 4) append 
}

foreach var in attractiveness_score message go_on_a_date relationship setup ///
 age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
 
 gen `var'm=1 if `var'==.
 replace `var'm=0 if `var'~=.
 
 }
 
 foreach var in  attractiveness_score message go_on_a_date relationship setup ///
 age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
tab `var'm
}

rename message respond_message
rename go_on_a_date go_date
rename setup   set_up_friend

keep same_party age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income attractiveness_scorem messagem go_on_a_datem relationshipm setupm agem malem educm whitem democrat_respondentm ideo5m employedm straightm transm religiositym poli_interestm incomem attractiveness_score respond_message go_date relationship set_up_friend married

rename setupm  set_up_friendm
rename messagem respond_messagem 
rename relationshipm relationshipm
rename go_on_a_datem go_datem 

gen experiment=4
save "pared_balance_experiment_4.dta", replace


use "balance_experiment_4.dta", clear

gen t=coef/stderr

saveold "balance_experiment_4.dta", version(12) replace
		
